/*
  Name: DeadProxyClientMap.cpp
  Copyright:
  Author: Carl Chatfield
  Date: 16/01/08 24:21
  Description: Stores map data
*/

#include "DeadProxyClientMap.h"

GameMap::GameMap()
{
    memset(Map, 0, sizeof(Tile) * 8 * 18 * 14);
}

void GameMap::SetPos(Position pos)
{
    xabs = pos.x;
    yabs = pos.y;
    zabs = pos.z;
}

Position GameMap::GetPos()
{
    Position ret;
    ret.x = xabs;
    ret.y = yabs;
    ret.z = zabs;
    return ret;
}

Tile * GameMap::GetTile(Position pos)
{
    int x = pos.x % 18;
    int y = pos.y % 14;
    int z;
    if(zabs <= 7)                       //if we are above ground
    {
        z = pos.z;                      //then we can use the pos.z as the z index 
    } else {                            //if we are underground we see 2 floors above and below
        z = (pos.z - 6) % 5;
    }
    return &Map[x][y][z];
}

void GameMap::ClearTile(Tile * T)
{
    T->stackedObjectCount = 0;
}

void GameMap::AddThing(Tile * T, Thing * thing)
{
    memcpy(&(T->Things[T->stackedObjectCount]), thing, sizeof(Thing));
    T->stackedObjectCount++;
    delete thing;
}

void GameMap::ReplaceThing(Tile * T, int stackpos, Thing * thing)
{
}

void GameMap::RemoveThing(Tile * T, int stackpos)
{
}

void GameMap::MoveThing(Tile * T1, int stackpos, Tile * T2)
{
}
